package md5;

import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Test;
import org.springframework.util.DigestUtils;

import java.nio.charset.StandardCharsets;

public class UseRandomStringUtils {

    /**
     *
     */
    @Test
    public void test01(){
        String password = "196574";
        //生成指定长度的字母和数字的随机组合字符串
        String saltCode = RandomStringUtils.randomAlphanumeric(5);
        String passwordEncrypt = DigestUtils.md5DigestAsHex((password+saltCode).getBytes(StandardCharsets.UTF_8));
        System.out.println(passwordEncrypt);
    }

}
